home *** CD-ROM | disk | FTP | other *** search
/ BCI NET 2 / BCI NET 2.iso / archives / programming / gui / precog2_1.lha / Precognition2_1 / src / src.lha / Library / HSlider.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-12-16  |  3.4 KB  |  160 lines

  1. /* ==========================================================================
  2. **
  3. **                         HSlider.c
  4. ** ©1991 WILLISoft
  5. **
  6. ** ==========================================================================
  7. */
  8.  
  9. #include "minmax.h"
  10. #include "HSlider.h"
  11. #include "HSliderClass.h"
  12. #ifndef __GNUC__
  13. #include <clib/exec_protos.h>
  14. #include <clib/intuition_protos.h>
  15. #endif
  16. #ifdef __GNUC__
  17. #include <proto/exec.h>
  18. #include <proto/intuition.h>
  19. #endif
  20. #ifdef __SASC
  21. #include <proto/exec.h>
  22. #include <proto/intuition.h>
  23. #endif
  24. #include "amigamem.h"
  25.  
  26.  
  27. tPoint HSlider_AskSize( HSlider *self,
  28.                         PIXELS  Width,
  29.                         PIXELS  Height )
  30. {
  31.    tPoint size;
  32.  
  33.    size.x = MAX( Width,  20 );
  34.    size.y = MAX( Height, 10 );
  35.  
  36.    return size;
  37. }
  38.  
  39.  
  40.  
  41. LONG HSlider_Value( HSlider *self )
  42. {
  43.    return self->Prop.HorizPot;
  44. }
  45.  
  46.  
  47. USHORT HSlider_KnobSize( HSlider *self )
  48. {
  49.    return self->Prop.HorizBody;
  50. }
  51.  
  52.  
  53. LONG HSlider_SetValue( HSlider *self, LONG value )
  54. {
  55.    struct pcgWindow *window;
  56.    struct PropInfo   propinfo;
  57.    USHORT position;
  58.  
  59.    position = value;
  60.    propinfo = self->Prop;
  61.  
  62.    if( ( window = InteractorWindow( (Interactor *)self ) ) &&
  63.        ( window->Window ) )
  64.    {
  65.       NewModifyProp( &self->eg.g, window->Window, NULL, propinfo.Flags,
  66.          position, propinfo.VertPot,
  67.          propinfo.HorizBody, propinfo.VertBody,
  68.          1 );
  69.    }
  70.    else
  71.    {
  72.       self->Prop.HorizPot  = position;
  73.    }
  74.  
  75.    return position;
  76. }
  77.  
  78.  
  79. USHORT HSlider_SetKnobSize( HSlider *self, USHORT knobsize )
  80. {
  81.    struct pcgWindow *window;
  82.    struct PropInfo   propinfo;
  83.  
  84.    propinfo = self->Prop;
  85.  
  86.    if( ( window = InteractorWindow( (Interactor *)self ) ) &&
  87.        ( window->Window ) )
  88.    {
  89.       NewModifyProp( &self->eg.g, window->Window, NULL, propinfo.Flags,
  90.          propinfo.HorizPot,  propinfo.VertPot,
  91.          knobsize, propinfo.VertBody,
  92.          1 );
  93.    }
  94.    else
  95.    {
  96.       self->Prop.HorizBody = knobsize;
  97.    }
  98.  
  99.    return knobsize;
  100. }
  101.  
  102.  
  103.  
  104.  
  105. BOOL HSlider_elaborated = FALSE;
  106.  
  107. struct PositionerClass HSlider_Class;
  108.  
  109. void HSliderClass_Init( struct PositionerClass *class )
  110. {
  111.    SliderClass_Init( class );
  112.    class->isa         = SliderClass();
  113.    class->ClassName   = "HSlider";
  114.    class->AskSize     = (Point(*)(GraphicObject *, PIXELS, PIXELS))HSlider_AskSize;
  115.    class->SetValue    = (LONG(*)(Valuator *, LONG))HSlider_SetValue;
  116.    class->Value       = (LONG(*)(Valuator *))HSlider_Value;
  117.    class->SetKnobSize = (USHORT(*)(Positioner *, USHORT))HSlider_SetKnobSize;
  118.    class->KnobSize    = (USHORT(*)(Positioner *))HSlider_KnobSize;
  119.  
  120. }
  121.  
  122.  
  123. struct PositionerClass *HSliderClass( void )
  124. {
  125.    if( ! HSlider_elaborated )
  126.    {
  127.       HSliderClass_Init( &HSlider_Class );
  128.       HSlider_elaborated = TRUE;
  129.    }
  130.  
  131.    return &HSlider_Class;
  132. }
  133.  
  134.  
  135. void HSlider_Init( HSlider    *self,
  136.                    PIXELS      LeftEdge,
  137.                    PIXELS      TopEdge,
  138.                    PIXELS      Width,
  139.                    PIXELS      Height,
  140.                    pcg_3DPens  Pens,
  141.                    char       *label )
  142. {
  143.    Point size;
  144.  
  145.    size = HSlider_AskSize( self, Width, Height );
  146.  
  147.    Slider_Init( self, LeftEdge, TopEdge, size.x, size.y, Pens );
  148.  
  149.    self->eg.isa        = HSliderClass();
  150.    self->Prop.Flags   |= FREEHORIZ;
  151.    self->Prop.HorizBody = 0x4000;
  152.  
  153.    SetTitle( (GraphicObject *)self, label );
  154.    SetTextAlignment( (GraphicObject *)self, tx_OUTSIDE | tx_LEFT | tx_YCENTER,
  155.       STD_XPAD, STD_YPAD );
  156. }
  157.  
  158.  
  159.  
  160.